package com.ithero.usercenter.rocketmq;

import com.ithero.usercenter.domain.dto.messaging.UserAddBonusMsgDTO;
import com.ithero.usercenter.service.user.UserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Rocket MQ 消费者监听，被{@link AddBonusStreamConsumer}取代
 */
@Slf4j
@Service
@RocketMQMessageListener(consumerGroup = "consumer-group", topic = "add-bonus")
public class AddBonusListener implements RocketMQListener<UserAddBonusMsgDTO> {

    @Autowired
    private UserService userService;

    @Override
    public void onMessage(UserAddBonusMsgDTO message) {
        // 当收到消息的时候执行的业务
        userService.addBonus(message);
    }
}
